package com.wwwarehouse.contract.import_realthing;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.fastjson.JSON;
import com.wwwarehouse.common.activity.base.BaseFragment;
import com.wwwarehouse.common.constant.Constant;
import com.wwwarehouse.common.eventbus_event.CardDeskEvent;
import com.wwwarehouse.contract.bean.ImoprtRealthingBean;
import com.wwwarehouse.contract.core.ContractConstant;

import contract.wwwarehouse.com.contract.R;
import de.greenrobot.event.EventBus;

/**
 * Creator by zhenwang.xiang on 2017/10/20 10:12
 * Description: 初始化库存导入成功
 */

@Route(path = ContractConstant.PATH_IMPORT_REALTHINGSUCCESS_FRAGMENT)
public class ImportRealthingSuccessFragment extends BaseFragment {

    private TextView mTvMessage;
    private TextView mTvMessageAddResource;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_import_realthing_success, container, false);

    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mTvMessage = $(R.id.tv_message);
        mTvMessageAddResource = $(R.id.tv_message_addresource);
        if (getArguments() != null) {
            String result = getArguments().getString(Constant.KEY_CONVER_TO_PC_IMPORT_SUCCESS);
            if (!TextUtils.isEmpty(result)) {
                ImoprtRealthingBean realthingBean = JSON.parseObject(result, ImoprtRealthingBean.class);
                if (realthingBean != null) {
                    ImoprtRealthingBean.MsgBean msg = realthingBean.getMsg();
                    if (msg != null) {
                        String message = "数据：" + msg.getData() + "; SKU：" + msg.getSKU() + "; 产品：" + msg.getProduct() + ";";
                        mTvMessage.setText(message);
                        mTvMessageAddResource.setText("相关的资源增加：" + msg.getAddresources());
                    }
                }

            }
        }
        $(R.id.btn_confirm).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(new CardDeskEvent("clear_back_stack"));
            }
        });
    }


    @Override
    public void setTitle() {
    }

    @Override
    public void requestDatas() {

    }
}
